package com.atguigu.edu.realtime.app.func;

import com.atguigu.edu.realtime.util.KeywordUtil;
import org.apache.flink.table.annotation.DataTypeHint;
import org.apache.flink.table.annotation.FunctionHint;
import org.apache.flink.table.functions.TableFunction;
import org.apache.flink.types.Row;

import java.util.List;

/**
 * @author Lec
 * @date 2022/8/23 19:38
 */

@FunctionHint(output = @DataTypeHint("ROW<word STRING>"))
public  class KeywordUDTF extends TableFunction<Row> {

    /*public void eval(String str) {
        for (String s : str.split(" ")) {
            // use collect(...) to emit a row
            collect(Row.of(s, s.length()));
        }
    }*/
    public void eval(String str) {
        List<String> list = KeywordUtil.analyze(str);
        for (String s : list) {
            collect(Row.of(s));

        }

    }
}
